package minh.bac.wcbrazil2014.listviewmatch;





import minh.bac.wcbrazil2014.R;
import minh.bac.wcbrazil2014.WCTAG;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


public class ListViewMatchFragment extends Fragment {
	
	static FragmentManager fragmentManager;
	public static ListViewMatchFragment newInstance()
	{
		ListViewMatchFragment fragment = new ListViewMatchFragment();
		return fragment;
	}
	
	
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		View rootView = inflater.inflate(R.layout.lichdau_layout, container, false);
		Log.d("LISTMatch", "listmatch createview");
		fragmentManager = getChildFragmentManager();
		switchFragment(R.id.container_viewpager_lichdau, new ViewPagerLichDau(), true, WCTAG.TAGFM_VONGBANG);
		return rootView;
	}
	
	@Override
	public void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		Log.d("LISTMatch", "listMatch resume");

	}

	public static void switchFragment(int idContainer, Fragment fragment ,boolean addToBackStack, String TAG)
	{
		if(addToBackStack)
		{
			if( TAG!= null )
			{
				fragmentManager.beginTransaction().replace(idContainer, fragment, TAG).addToBackStack(TAG).commit();
				
			}
			else
			{
				fragmentManager.beginTransaction().replace(idContainer, fragment).addToBackStack(null).commit();
			}
		}
		else
		{
			if( TAG!= null )
			{
				fragmentManager.beginTransaction().replace(idContainer, fragment, TAG).commit();
			}
			else
			{
				fragmentManager.beginTransaction().replace(idContainer, fragment).commit();
			}
		}
	}
	

}
